<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100%;
            height: 50px;
            background-color: #ccc;
            line-height: 50px;
            text-align: center;
        }
        #usname{
            color: green;
        }
    </style>
</head>
<body>
    <div>
        <span id="usname">xxx,欢迎你</span>
    </div>
    <script>
        //获取本地储存的用户名并且输出在span标签中
        window.onload = function(){
            var userInfo =JSON.parse(localStorage.getItem('userInfo'));
            if(userInfo){
                document.getElementById('usname').innerHTML = '欢迎你,'+userInfo.username;
            }
        }
    </script>
</body>
</html>